# common/exception/exception.py
from common.exception.exception_enum import BusiExceptionEnum


class BusiException(Exception):
    """ Inappropriate argument value (of correct type). """
    def __init__(self, exception_enum, *args, **kwargs):
        if not isinstance(exception_enum, BusiExceptionEnum):
            raise ValueError("exception_enum must be an instance of BusiExceptionEnum")
        self.code = exception_enum.code
        self.message = exception_enum.message
        super().__init__(self.message, *args, **kwargs)

    def __str__(self):
        return f"{self.code}: {self.message}"
